package com.example.coco.Controller;


import com.example.coco.model.Suggestion;
import com.example.coco.res.SuggestionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@RestController
public class Sug {
    @Autowired
    SuggestionMapper suggestionMapper;
    @RequestMapping("/about")
    @ResponseBody
    public Object insertsug(@RequestParam Map<String, Object> params){
        String userid = (String) params.get("userid");
        String email = (String) params.get("email");
        String tel = (String) params.get("tel");
        String body = (String) params.get("body");
        Suggestion suggestion = new Suggestion();
        suggestion.setUserid(userid);
        suggestion.setEmail(email);
        suggestion.setTel(tel);
        suggestion.setBody(body);
        suggestionMapper.addSuggestion(suggestion);
        return new ModelAndView("suggestionShow");
    }
}
